#include <iostream>
#include <queue>
#include <string>

using namespace std;

string simplifyPath(string path)
{
	deque<string> pathStack;
	string part;
	int startIndex = 0;
	bool finish = false;
	while (!finish)
	{
		int index = path.find_first_of('/', startIndex+1);
		if (index == -1)
		{
			part = path.substr(startIndex + 1, path.size() - startIndex - 1);
			finish = true;
		}
		else
		{
			part = path.substr(startIndex + 1, index - startIndex - 1);
		}
		cout << part << endl;
		if (part == "..")
		{
			if (!pathStack.empty())
				pathStack.pop_back();
		}
		else if (part == "" || part == ".")
		{

		}
		else
		{
			pathStack.push_back(part);
		}
		startIndex = index;
	}
	string result = "";
	if (pathStack.empty())
	{
		return "/";
	}
	while (!pathStack.empty())
	{
		result.push_back( '/');
		result.append( pathStack.front());
		pathStack.pop_front();
	}
	return result;
}
int main()
{
	//string path = "/a/./b/../../c/";
	string path = "/a//b////c/d//././/..";
	cout << simplifyPath(path) << endl;
	return 0;
}